<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" omit-xml-declaration="yes"/>

  <xsl:param name="jsx_id">abcdefg</xsl:param>

  <xsl:template match="/">
    <xsl:for-each select="//record[not((@hasCachedImages='1' and not(img)) or @pic='')]">
      <span class="search_thumb_span_container" style="margin-right:2px;height:;vertical-align:top;border:solid 1px #dededf;overflow:;" title="{@jsxtext}">
      <xsl:choose>
        <xsl:when test="(@hasCachedImages='1' and not(img)) or @pic=''">
          <div title="no pictures" style="float:left;margin-bottom:6px;">&#160;</div>
        </xsl:when>
        <xsl:when test="(@pic='pic' and not(@hasCachedImages='1')) or (@hasCachedImages='1' and @hideCachedImages='1')">
          <span style="float:left;margin-bottom:6px;" class="get_image_link" onclick="gicx.prefetchImages('{@jsxid}','mtxSearchResults');jsx3.gui.Event.wrap(event).cancelAll();">view pictures</span>
        </xsl:when>
        <xsl:otherwise>
          <span class="get_image_link" style="float:left;margin-bottom:6px;"><span onclick="gicx.hideCachedImages(gicx.APP.getJSX('mtxSearchResults'),'{@jsxid}');">hide pictures</span><br/><span class="get_posting_link" style="float:left;clear:left;text-decoration:underline;" onclick="gicx.openPosting('{@jsxid}');">open posting</span></span>
          <span id="{@jsxid}" class="search_thumb_span_container" ondblclick="gicx.openPosting('{@jsxid}');" onmouseover="gicx.doSpyThumb(this,event,true);" onmouseout="gicx.doSpyThumb(this,event,false);">
            <xsl:apply-templates select="img">
              <xsl:with-param name="jsxid" select="@jsxid"/>
            </xsl:apply-templates>
          </span>
        </xsl:otherwise>
      </xsl:choose>
      </span>
    </xsl:for-each>
  </xsl:template>

  <xsl:template match="img">
    <xsl:param name="jsxid"/>
    <span jri="{$jsxid}" class="search_thumb_span full_round"><div jri="{$jsxid}" class="search_thumb_div full_round"><img jri="{$jsxid}" class="search_thumb" onload="gicx.doMakeThumb(this,'{$jsx_id}');" src="{@src}"/></div></span>
  </xsl:template>

</xsl:stylesheet>